<template>
  <div>
    <!-- 面包屑 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>课程管理</el-breadcrumb-item>
      <el-breadcrumb-item>课程列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片 -->
    <el-card class="box-card">
      <!-- 表格 -->
      <el-table :data="classlist">
        <el-table-column type="index"></el-table-column>
        <el-table-column label="课程序号" prop="classId"></el-table-column>
        <el-table-column label="课程名称" prop="className"></el-table-column>
        <el-table-column label="教室" prop="classPlace"></el-table-column>
        <el-table-column label="教师" prop="classTeacher"></el-table-column>
        <el-table-column label="专业" prop="classMaior"></el-table-column>
        <el-table-column label="学分" prop="classCredit"></el-table-column>
      </el-table>
      <!-- 分页 -->
      <el-pagination
        @current-change="currentchange" 
        layout="prev, pager, next"
        :total="50"
        :current-page="page"
      >
      </el-pagination>
      
    </el-card>
  </div>
</template>

<script>
import axios from "axios";

export default {
  data() {
    return {
      classlist: [], //课程列表
      page: 1,
    };
  },
  methods: {
    // 获得课程列表
    getclasslist() {
      axios
        .post("http://localhost:3000/getclasslist", {
          page: this.page,
        })
        .then((res) => {
          this.classlist = res.data;
        });
    },
    currentchange(val){
      this.page = val
      this.getclasslist()
    }
  },
  created() {
    this.getclasslist();

    const h = this.$createElement;

    this.$notify({
      title: "课程列表",
      position: "bottom-left",
      message: h("i", { style: "color: teal" }, "2021年秋"),
    });
  },
};
</script>

<style>
</style>